{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Evaluation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data : train_nlp_trans.npy train_label.npy\n",
      "[completed] load data\n",
      "load data : dev_nlp_trans.npy dev_label.npy\n",
      "[completed] load data\n",
      "load data : test_nlp_trans.npy test_label.npy\n",
      "[completed] load data\n"
     ]
    }
   ],
   "source": [
    "from SE_model_text import *\n",
    "import os\n",
    "from process_data_text import *\n",
    "from evaluation_text import *\n",
    "batch_gen = ProcessDataText(data_path='../data/target/audio_woZ_set01/')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[launch-text] placeholders\n",
      "[launch-text] create embedding\n",
      "[launch-text] use pre-trained embedding\n",
      "[launch-text] create gru cell\n",
      "[launch-text] create output projection layer\n",
      "[launch-text] create optimizer\n",
      "[launch-text] create summary\n"
     ]
    }
   ],
   "source": [
    "batch_size = 200\n",
    "encoder_size = 128\n",
    "num_layer = 1\n",
    "hidden_dim = 200\n",
    "lr = 1e-3\n",
    "dr = 1.0\n",
    "model = SingleEncoderModelText(\n",
    "            dic_size=batch_gen.dic_size,\n",
    "            use_glove=1,\n",
    "            batch_size=batch_size,\n",
    "            encoder_size=encoder_size,\n",
    "            num_layer=num_layer,\n",
    "            hidden_dim=hidden_dim,\n",
    "            lr = lr,\n",
    "            dr=1.0\n",
    "            )\n",
    "\n",
    "model.build_graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "from check point!!!\n",
      "INFO:tensorflow:Restoring parameters from ./save/SE_nlp_Daudio_woZ_set01_b128_es128_L1_H200_G1_dr0.3_03-26-23-51/-539\n"
     ]
    }
   ],
   "source": [
    "saver = tf.train.Saver()\n",
    "config = tf.ConfigProto()\n",
    "config.gpu_options.allow_growth = True\n",
    "\n",
    "sess = tf.Session(config=config)\n",
    "sess.run(tf.global_variables_initializer())\n",
    "\n",
    "ckpt = tf.train.get_checkpoint_state(os.path.dirname( './save/SE_nlp_Daudio_woZ_set01_b128_es128_L1_H200_G1_dr0.3_03-26-23-51/' ))\n",
    "if ckpt and ckpt.model_checkpoint_path:\n",
    "    print ('from check point!!!')\n",
    "    saver.restore(sess, ckpt.model_checkpoint_path)\n",
    "else :\n",
    "    print \"ERROR no model file in : \""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "test_ce, test_accr, _, _ = run_test(sess=sess,\n",
    "                                     model=model, \n",
    "                                     batch_gen=batch_gen,\n",
    "                                     data=batch_gen.test_set)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda env:tf14_p27]",
   "language": "python",
   "name": "conda-env-tf14_p27-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
